package org.limkokwing.hami.ui.form;

import com.sun.lwuit.Command;
import com.sun.lwuit.Container;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.RadioButton;
import com.sun.lwuit.TextField;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.layouts.BoxLayout;

/**
 * @author Mohammad
 */
public class ProfileFormHandler extends FormHandler {

    public String getName() {
        return "Profile";
    }

    public String getTitle() {
        return "Profile";
    }

     public void cleanup() {
     }

    public String getHelp() {
        return "The toolkit supports 5 different Layouts: FlowLayout, BorderLayout, BoxLayout, GridLayout and GroupLayout." +
                "In this Demo we added 5 Components to the Form and we changes the Layout and rearrange the Components" +
                "A developer can add his own Layout by extending the Layout class";
    }

    protected void execute(final Form f) {
        f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        Label nameLabel = new Label("Name:");
        TextField nameText = new TextField("my name");
        Label emailLabel = new Label("E-mail:");
        TextField emailText = new TextField("my email");
        Label ageLabel = new Label("Age:");
        TextField ageText = new TextField("my age");
        Label genderLabel = new Label("Gender:");
        RadioButton male = new RadioButton("Male");
        RadioButton female = new RadioButton("Femail");
        Container genderContainer = new Container(new BoxLayout(BoxLayout.X_AXIS));
        genderContainer.addComponent(male);
        genderContainer.addComponent(female);
        Label countryLabel = new Label("Country:");
        TextField countryText = new TextField("my country");
        Label cityLabel = new Label("City:");
        TextField cityText = new TextField("my city");

        f.addComponent(nameLabel);
        f.addComponent(nameText);
        f.addComponent(emailLabel);
        f.addComponent(emailText);
        f.addComponent(ageLabel);
        f.addComponent(ageText);
        f.addComponent(genderLabel);
        f.addComponent(genderContainer);
        f.addComponent(countryLabel);
        f.addComponent(countryText);
        f.addComponent(cityLabel);
        f.addComponent(cityText);

        f.addCommand(new Command("Save") {

            public void actionPerformed(ActionEvent evt) {
            }

        });
        
        f.show();
    }
}